# IO Programming
read_file = open('read.txt', 'r', encoding='utf-8')
print(read_file.read())
read_file.close()
# with 简写方式，自动close,有中文时要指定编码
with open('E:\\personal\\python\\test-doc\\abc.txt', 'r', encoding='utf-8') as f:
    print(f.read())

# 文件很大时候，用readlines()，一行一行读
with open('E:\\personal\\python\\test-doc\\abc.txt', 'r', encoding='utf-8') as f:
    for line in f.readlines():
        print(line.strip())  # strip()去掉行末的换行符

# 读二进制文件
with open('E:\\personal\\python\\test-doc\\abc.txt', 'rb') as f:
    print(f.read())